describe('practice-3-8', function () {

    it("求三位数中所有的黑洞数", function () {
        var arr_hole_number = three_black_hole_number();
        console.info('arr_hole_number:'+arr_hole_number+'length:'+arr_hole_number.length);
        expect(arr_hole_number.length).toBe(1);
        for(var i = 0;i < arr_hole_number.length; i ++)
        {
            var diff = get_diff(arr_hole_number[i]);
            expect(get_diff(diff)).toBe(diff);
        }
    });

});

function get_diff(number)
{
    var arr_value = [];
    var str_number = number.toString();
    var high = parseInt(str_number.substr(0,1),0);
    for(var i = 0; i < 3; i ++)
    {
        var num = parseInt(str_number.substr(i,1),0);
        if(high<num)
        {
            high = num;
        }
        else
        {
            arr_value.push(num);
        }
    }

    var low = arr_value[0]<arr_value[1]?arr_value[0]:arr_value[1];
    var mid = arr_value[0]>arr_value[1]?arr_value[0]:arr_value[1];

    return (high*100+mid*10+low)-(low*100+mid*10+high);
}